package io.renren.modules.job.task;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import io.renren.common.utils.PublicUtil;
import io.renren.common.utils.RedisUtils;
import io.renren.modules.udp.entity.R5rmObjectsEntity;
import io.renren.modules.udp.entity.R5rmSkillstatusEntity;
import io.renren.modules.udp.service.R5rmObjectsService;
import io.renren.modules.udp.service.R5rmSkillstatusService;
import io.renren.modules.udp.utils.UdpClient;
import io.renren.modules.udp.utils.UdpStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

/**
 * @author Jackie
 * @version 1.0
 * @date 2020/1/8 16:40
 * @description
 */
@Component("udpTask")
public class UdpTask {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Resource
    private R5rmObjectsService objectsService;

    public void cron1(){
        int port = 905;
        String context = "";
		String user = "fjljkm";
		String pswd = "fjljkm";
		String msgtype = "03";
		String filelength = "01 30";
		String accesspswd = "00000000";

        List<R5rmObjectsEntity> r5rmObjectsEntities = objectsService.selectList(new EntityWrapper<>());
        for (R5rmObjectsEntity r5rmObjectsEntity : r5rmObjectsEntities) {
            context = UdpClient.getContext(user,pswd,msgtype,filelength,r5rmObjectsEntity.getObjCode(),accesspswd).trim();
            try {
                new UdpClient().run(port, context);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    public void cron2(){
        int port = 905;
        String context = "";
        String user = "fjljkm";
        String pswd = "fjljkm";
        String msgtype = "04";
        String filelength = "01 30";
        String accesspswd = "00000000";
        List<R5rmObjectsEntity> r5rmObjectsEntities = objectsService.selectList(new EntityWrapper<>());
        for (R5rmObjectsEntity r5rmObjectsEntity : r5rmObjectsEntities) {
            context = UdpClient.getContext(user,pswd,msgtype,filelength,r5rmObjectsEntity.getObjCode(),accesspswd).trim();
            try {
                new UdpClient().run(port, context);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
